package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;


/** enter page by Ticketing \ New Incident(Call Center)*/
public class SpNewIncidentPageUtil extends SeleniumPageUtil {
	
	// data fields
	public final static By NI_BTN_CREATE_SAVE = By.id("ctl44_btnSave");
	public final static By NI_BTN_CLEAR = By.id("ctl44_btnClear");
	public final static By NI_BTN_CLOSE = By.id("ctl44_btnDone");
	public final static By NI_INPUT_CUSTOMER = By.id("ctl44_txtCustomer");
	public final static By NI_INPUT_CONTRACT = By.id("ctl44_txtContract");
	public final static By NI_INPUT_LINE = By.id("ctl44_txtLine");
	public final static By NI_INPUT_SERIAL_NUMBER = By.id("ctl44_txtSerialNumber");
	public final static By NI_INPUT_SERVICE_PARTNER = By.id("ctl44_txtPartner");
	public final static By NI_INPUT_ASSET_NODE_NAME = By.id("ctl44_txtAssetName");
	public final static By NI_INPUT_REQUESTOR = By.id("ctl44_txtRequestor");
	public final static By NI_INPUT_REQUESTOR_EMAIL = By.id("ctl44_txtEMail_Req");
	public final static By NI_INPUT_REQUESTOR_OFFICE_PHONE = By.id("ctl44_txtPhone_Req");
	public final static By NI_INPUT_REQUESTOR_MOBILE_PHONE = By.id("ctl44_txtMobile_Req");
	public final static By NI_INPUT_PT_OF_CONTACT = By.id("ctl44_txtContact");
	public final static By NI_INPUT_PT_OF_CONTACT_EMAIL = By.id("ctl44_txtEMail");
	public final static By NI_INPUT_PT_OF_CONTACT_OFFICE_PHONE = By.id("ctl44_txtPhone");
	public final static By NI_INPUT_PT_OF_CONTACT_MOBILE_PHONE = By.id("ctl44_txtMobile");
	public final static By NI_INPUT_CUSTOMER_TICKET_NUMBER = By.id("ctl44_txtCustomerTicketNumber");
	public final static By NI_SELECT_PRIORITY = By.id("ctl44_cboPriorityCodeKey");
	public final static By NI_SELECT_SRO_TYPE = By.id("ctl44_cboSroType");
	public final static By NI_INPUT_SHORT_DESCRIPTION = By.id("ctl44_txtDescription");
	
	public final static By NI_SELECT_GENERIC_REASON = By.id("ctl44_cboGenericReason");
	public final static By NI_SELECT_SPECIFIC_REASON = By.id("ctl44_cboSpecificReason");
	public final static By NI_INPUT_NOTES_REASON = By.id("ctl44_txtNotes");
	public final static By NI_INPUT_ASSIGNED_TO = By.id("ctl44_txtAssignedTo");
	public final static By NI_CHECKBOX_F_E_CALLED = By.id("ctl44_chkFieldEngineerCalled");
	public final static By NI_INPUT_FOLLOW_UP_TIME = By.id("ctl44_dteFollowUpDate_txtDatePart");
	public final static By NI_SPAN_SLA_TERMS = By.id("ctl44_lblSLATerm");
	public final static By NI_SPAN_ASSET_DETAILS = By.id("ctl44_lblAsset");
	public final static By NI_INPUT_DEFERED_BY = By.id("ctl44_txtDeferedBy");
	public final static By NI_INPUT_ADDRESS = By.id("ctl44_txtAddress");
	public final static By NI_INPUT_WAREHOUSE = By.id("ctl44_txtWarehouse");
	public final static By NI_RADIO_RESCHEDULE = By.id("ctl44_rdoReschedule");
	public final static By NI_IMG_DATE = By.id("ctl44_dteFollowUpDate_imgDateCalendar");
	public final static By NI_DIV_DATE_TODAY = By.id("ctl44_dteFollowUpDate_txtDatePart_CalendarExtender_today");
	
	// close button in Notes extra info window
	public final static By NI_BTN_CLOSE_NOTES = By.id("ctl44_linkBtnNotesClose");
	
	// labels
	public final static By NI_LBL_CUSTOMER = By.id("ctl44_lblCustomer");
	public final static By NI_LBL_CUSTOMER_REQD = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[1]/table/tbody/tr[2]/td[1]/span[2]");
	public final static By NI_LBL_CUSTOMER_TICKET_NUMBER = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[1]/td[1]");
	public final static By NI_LBL_CONTRACT = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[1]/td[1]");
	public final static By NI_LBL_PRIORITY = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]");
	public final static By NI_LBL_LINE = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[2]/td[1]");
	public final static By NI_LBL_SRO_TYPE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[3]/td[1]");
	public final static By NI_LBL_SERIAL_NUMBER = By.id("ctl44_lblSerialNumber");
	public final static By NI_LBL_SHORT_DESCRIPTION = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[4]/td[1]");
	public final static By NI_LBL_SERVICE_PARTNER = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[4]/td[1]");
	public final static By NI_LBL_GENERIC_REASON = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[5]/td[1]");
	public final static By NI_LBL_ASSERT_NAME = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[5]/td[1]");
	public final static By NI_LBL_REQUESTOR = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[6]/td[1]");
	public final static By NI_LBL_SPECIFIC_REASON = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[6]/td[1]");
	public final static By NI_LBL_EMAIL_1 = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[7]/td[1]");
	public final static By NI_LBL_OFFICE_PHONE_1 = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[8]/td[1]");
	public final static By NI_LBL_MOBILE_PHONE_1 = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[9]/td[1]");
	public final static By NI_LBL_NOTESORREASON = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[7]/td[1]");
	public final static By NI_LBL_PTOFCONTACT = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[10]/td[1]");
	public final static By NI_LBL_EMAIL_2 = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[11]/td[1]");
	public final static By NI_LBL_OFFICE_PHONE_2 = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[12]/td[1]");
	public final static By NI_LBL_ASSIGEND_TO = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[8]/td[1]");
	public final static By NI_LBL_MOBILE_PHONE_2 = By.xpath("//*[@id='ctl44_pnlKnownCustomers1']/table/tbody/tr[13]/td[1]");
	public final static By NI_LBL_FECALLED = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[9]/td[1]");
	public final static By NI_LBL_FOLLOW_UP_TIME = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[2]/table/tbody/tr[10]/td[1]");
	public final static By NI_LBL_SLA_TERMS = By.xpath("//*[@id='ctl44_pnlKnownCustomers2']/table/tbody/tr/td[1]/table/tbody/tr[1]/td[1]");
	public final static By NI_LBL_ADDRESS = By.xpath("//*[@id='ctl44_pnlKnownCustomers2']/table/tbody/tr/td[2]/table/tbody/tr[1]/td[1]");
	public final static By NI_LBL_ASSET_DETAILS = By.xpath("//*[@id='ctl44_pnlKnownCustomers2']/table/tbody/tr/td[1]/table/tbody/tr[2]/td[1]");
	public final static By NI_LBL_WAREHOUSE = By.xpath("//*[@id='ctl44_pnlKnownCustomers2']/table/tbody/tr/td[2]/table/tbody/tr[4]/td[1]");
	
	public final static By NI_SELECT_HOUR = By.id("ctl44_dteFollowUpDate_cboHour");
	public final static By NI_SELECT_MINUTE = By.id("ctl44_dteFollowUpDate_cboMinute");
	public final static By NI_SELECT_MERIDIEM = By.id("ctl44_dteFollowUpDate_cboMeridiem");
	
	// drop down list
	public final static By NI_DIV_SELECTION_CUSTOMER = By.id("ctl44_aceCustomer_completionListElem");
	public final static By NI_DIV_SELECTION_CONTRACT = By.id("ctl44_aceContract_completionListElem");
	public final static By NI_DIV_SELECTION_PT_CONTACT = By.id("ctl44_aceContact_completionListElem");
	public final static By NI_DIV_SELECTION_REQUESTOR = By.id("ctl44_aceRequestor_completionListElem");
	public final static By NI_DIV_SELECTION_SERIAL_NUMBER = By.id("ctl44_aceSerialNumber_completionListElem");
	public final static By NI_DIV_SELECTION_ADDRESS = By.id("ctl44_aceAddress_completionListElem");
	public final static By NI_DIV_DEFERED_BY = By.id("ctl44_acDeferedBy_completionListElem");
	
	// note panel
	public final static By NI_DIV_PANEL_NOTES = By.id("ctl44_panelNotes");
	
	// the edit link under address input text
	public final static By NI_LINK_EDIT_ADDRESS = By.id("ctl44_btnAddressEdit");
	
	
	public final static WebElement getNtButtonCreateSave(){
		return SeleniumUtil.getCachedElement(NI_BTN_CREATE_SAVE);
	}
	
	public final static WebElement getNtButtonClear(){
		return SeleniumUtil.getCachedElement(NI_BTN_CLEAR);
	}
	
	public final static WebElement getNtButtonClose(){
		return SeleniumUtil.getCachedElement(NI_BTN_CLOSE);
	}
	
	public final static void enter(){
		SpHomePageUtil.enter();
		SpHomePageUtil.enterNewIncidentPage();
	}

	public final static void waitForPageToLoad() {
		// Wait on some typical elements is ok
		SeleniumUtil.waitOnElements(new By[]{
				NI_BTN_CREATE_SAVE, NI_BTN_CLEAR, NI_BTN_CLOSE, 
				NI_SELECT_PRIORITY, NI_SELECT_SRO_TYPE, NI_SELECT_GENERIC_REASON, 
				NI_SELECT_SPECIFIC_REASON
			});
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(NI_SELECT_PRIORITY));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(NI_SELECT_SRO_TYPE));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(NI_SELECT_GENERIC_REASON));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(NI_SELECT_SPECIFIC_REASON));
	}	
	
}
